<?php

use think\migration\Migrator;
use think\migration\db\Column;

class CarCalendars extends Migrator
{
    public function up()
    {
        $users = $this->table('caravan_calendar', array('comment' => '会员房车时间段状态表'));
        $users->addColumn('user_id', 'integer', array('limit' => 5, 'comment' => '房车所有者id'))
              ->addColumn('caravan_id', 'integer', array('limit' => 5, 'comment' => '房车id'))
              ->addColumn('camp_id', 'integer', array('limit' => 3, 'comment' => '所属营地id'))
              ->addColumn('branch_id', 'integer', array('limit' => 3, 'comment' => '所属分公司id'))
              ->addColumn('car_area', 'string', array('limit' => 10, 'comment' => '所属地区'))
              ->addColumn('sign', 'string', array('limit' => 10, 'comment' => '时间段类型'))
              ->addColumn('s', 'date', array('comment' => '时间段开始日期'))
              ->addColumn('e', 'date', array('comment' => '时间段结束日期'))
              ->addColumn('created_at', 'timestamp', array('null' => true))
              ->addColumn('updated_at', 'timestamp', array('null' => true))
              ->addIndex('caravan_id')
              ->save();     
    }

    /**
     * Migrate Down.
     */
    public function down()
    {
        $this->dropTable('caravan_calendar');
    }
}
